<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
	This is a simple IFrame integration contents page for the TagsEditor.

	Initially used together with the Greasemonkey user scripts, however
	could be easily reused for any other IFrame-based integration.
-->
<html>
  <head>
    <title>Greasemonkey integration page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
    <script type="text/javascript" src="../../../../admin/js/jquery-ui-1.8.9.custom/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../../../../admin/js/jquery-ui-1.8.9.custom/js/jquery-ui-1.8.9.custom.min.js"></script>

	<!-- Needed only for this integration due to bug KIWING-63 -->
	<script type="text/javascript" src="md5.js"></script>

	<!-- TagsEditor widget files -->
	<script type="text/javascript" src="../TagsEditor.js"></script>
	<script type="text/javascript" src="../HierarchyBrowser.js"></script>
	<link rel="stylesheet" href="../TagsEditor.css" type="text/css"/>
	
  </head>
  <body class="collapsed inIframe">
    <script type="text/javascript">
		$(document).ready(function(){
			$("#container").TagsEditor({
				// This should normally work ...
				resourceURI : window.location.hash.substr(1),

				// But due to bug KIWING-63, we rather provide "local resource URL" based on
				// MD5 of current URL
				//resourceURI : "http://localhost:8080/KiWi2/resource/" + hex_md5(window.location.hash.substr(1)),

				// Needed for Cross Frame communication (if embedded via User Script)
				// A click on the LMF logo in the TagsEditor widget collapses
				// the editor by setting #collapse on the outter frame
				outterWindowURL : window.location.hash.substr(1)
			});

			/*
			 * This is needed if this document is loaded in an IFrame
			 * (typically by the greasemonkey user script). If the "expand"
			 * button is clicked in the outter frame, it changes the location
			 * hash in this frame to "#expanded", which is a signal for
			 * the widget to switch to the expanded mode.
			 */
			window.setInterval(function(){
				if (window.location.hash == "#expanded") {
					window.location.hash = "";
					document.body.className = "inIframe";
					$("#container").data("TagsEditor").focus();
				}
			}, 100);
		});
	</script>
	<div id="container"></div>
  </body>
</html>
